<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Date" %>
<%@ page import="com.wy.util.DBUtil" %><%--
  Created by IntelliJ IDEA.
  User: 13939
  Date: 2024/12/2
  Time: 10:26
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String hid = request.getParameter("hid");
    Integer uid = (Integer) session.getAttribute("uid");
    Date now = new Date();
    String newsTitle = request.getParameter("newsTitle");
    String newsContent = request.getParameter("newsContent");
    String newsCategory = request.getParameter("newsCategory");
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String formattedDate = sdf.format(now);

    DBUtil dbUtil = new DBUtil();
    String sql = "UPDATE news_headline SET " +
            "title = '" + newsTitle + "', " +
            "article = '" + newsContent + "', " +
            "type = '" + newsCategory + "', " +
            "publisher = '" + uid + "', " +
            "page_views = 0, " +
            "create_time = '" + formattedDate + "', " +
            "update_time = '" + formattedDate + "', " +
            "is_deleted = 0 " +
            "WHERE hid = " + hid + ";";
    int n = dbUtil.update(sql);
    if (n > 0) {
        response.sendRedirect("updateSuccess.jsp");
    } else {
        out.print("增加失败!");
    }%>